package com.zjl.cms.interceptor;

import java.util.List;

import javax.servlet.ServletContext;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;

import com.zjl.cms.model.Config;
import com.zjl.cms.service.ConfigService;


 

@Component
public class StartupInterceptor implements InitializingBean, ServletContextAware {
	private static Logger logger = Logger.getLogger(StartupInterceptor.class);
	@Autowired
	private ConfigService configService;
	
	private ServletContext servletContext;

	/**
	 * 加载参数到系统
	 *
	 */
	private void loadParams() {
		logger.info("开始加载网站配置");
		int size=configService.getAllConfig(servletContext);
		
		logger.info("成功加载"+size+"条配置");
		logger.info(servletContext.getRealPath("/"));
	}

	/**
	 * 加载配置信息到系统
	 * 
	 */
	private void loadConfig() {
		//System.out.println("==================加载配置信息到系统");
    }

	public void setServletContext(ServletContext servletContext) {
		this.servletContext=servletContext;
		
	}

	public void afterPropertiesSet() throws Exception {
		loadParams();
		loadConfig();
	}

	
}